<?php
ob_start();
session_cache_expire(999999999);
if(!isset($_SESSION)){ 
	session_start(); 
} 
if(!isset($_SESSION['user'])){
	echo "timeout";
}else{
	
	$username = $_SESSION['fullname'];
	$id_employee = $_SESSION['IDEmployee'];
include '../operations/connection.php';	
$a= (string)(microtime(true)*1000);
$b=split('\.',$a);
$idcommentA= $b[0];
if ($_REQUEST['newlang'] == "EN") {
			include "../value/value_en.php";
		}else if($_REQUEST['newlang'] == "VN") {
			include "../value/value_vn.php";
		}else{
			include "../value/value_kr.php";
		}
		

	
		
//$datecomment = NOW();
$idtestproject = $_REQUEST['idtestpro'];
$idemploy =$_REQUEST['idemp'];
$comment = mysql_real_escape_string($_REQUEST['comment']);
$code =$_REQUEST['code'];
//echo $comment;
if($comment!=""){
$stylecolor = $_REQUEST['stylecolor'];

if ($_REQUEST['newlang'] == "EN") {
			$commentvalue=$username." choose $code DeadLine time : ".str_replace('\\r\\n','<br>',$comment."-%$#@!-#".$stylecolor);
}else if($_REQUEST['newlang'] == "VN") {
			$commentvalue=$username." đã chọn hạn cuối của $code  là : ".str_replace('\\r\\n','<br>',$comment."-%$#@!-#".$stylecolor);
}else{
			$commentvalue=$username."이(가) $code의 완료일을 ".str_replace('\\r\\n','<br>',$comment."-%$#@!-#".$stylecolor)."로 설정했다";
}
$sqladdcomment = "insert into pr_comment(IDComment,IDTestProject,IDEmployee,`Comment`,DateComment)
 VALUES('$idcommentA','$idtestproject','$idemploy','$commentvalue',NOW())";

//mysql_query($sqladdcomment);

//$sqlinserttestpro = "UPDATE pr_testproject SET Comment_Last = '$commentvalue', NameEmployee_Last = '$username' , DeadLine = '$comment'
//						WHERE IDTest = '$idtestproject' ";
$sqlinserttestpro = "UPDATE pr_testproject SET DeadLine = '$comment'
						WHERE IDTest = '$idtestproject' ";
mysql_query($sqlinserttestpro);

}
$querycomment = mysql_query("select c.IDComment,c.IDTestProject,c.IDEmployee,c.Comment,c.DateComment,
								 e.IDEmployee,e.FullName,c.IDTestProject from pr_comment c, employee e 
									 where c.IDEmployee = e.IDEmployee and c.IDTestProject = '$idtestproject' ORDER BY  c.DateComment ASC;")
?>
	                        <?php 
	                        if(count($querycomment)>0){
	                        	?>
					              <table style="width: 100%;">
					                        <?php  
						                        $vitri=0;
						                        while ($rowcoment = mysql_fetch_array($querycomment)){
						                        	$vitri++;
						                        		$idcomment = $rowcoment['IDComment'];
						                        		$idemployeecomment = $rowcoment['IDEmployee'];
														$stringcolor = substr($rowcoment['Comment'],0,-14);
														$listattachcomment = mysql_query('select id, commentid, filepath, filereal, filename, filetype, filesize, createdate
															 from pre_commentattach where commentid='.$idcomment);?>
												<tr id="mo" style="background: <?php if($vitri%2==0) echo '#f2f9ff'; else echo '#ffffff';?>; font-size: 13px;">
													<td class="rf-dt-c" style="padding: 0; vertical-align: middle; width: auto;">
							                        	<span style="font-size: 13px;">
							                        		<?php if (strlen($stringcolor)==0){
							                        			echo " + ".$rowcoment['Comment'];
							                        		}else{
							                        			echo " + ".$stringcolor;
							                        		}?>
														</span>
															<?php 
																while ($rowattachC = mysql_fetch_array($listattachcomment)) {?>
															<div style="padding:1px"><img src="images/dinhkem.png"/>
																<a href="admin/attachcomment/downloadattach.php?filepath=<?=$rowattachC['filereal']?>&filename=<?=$rowattachC['filename']?>&filetype=<?=$rowattachC['filetype']?>">
																	<?=$rowattachC['filename']."(".$rowattachC['filetype'].") ".$rowattachC['filesize']?></a>
															</div>
															<?php }?>
						                            	<i style="color:#424242; display:block; text-align:right; padding-top:5px;padding-right:15px; font-size: 13px;"><?php echo $rowcoment['FullName']." (".$rowcoment['DateComment'].")"?></i>
						                           </td>
						                           <td class="rf-dt-c" style="width: 25px; vertical-align: middle; text-align: center;min-width: 80px">
							                          <?php 
														if($_SESSION['posmanager']==1){?>
							                          <span onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" style="color:#236DA4" onclick="if(confirm('<?php echo $l_confirm_deleteproject?>')){ delete_comment('<?=$idcomment?>','<?=$idtestproject?>','<?=$id_employee?>',this);return true}else{return false}">[ <?=$l_delete?> ]</span>
							                         <?php }else {}?>
												   </td>
											  </tr>
					                  	 <?php }?>
					              		 </table>
	               <?php }
mysql_close($connection);
}
ob_flush();
?>